import { NextResponse } from 'next/server'; import { connectorAction } from '@/lib/admin/actions'; export const runtime = 'nodejs'; /** JSON twin of the control-center buttons (for scripts/agents): POST /api/admin/connectors/:id/:action with the admin cookie. */ export async function POST(_req: Request, ctx: { params: Promise<{ id: string; action: string }> }) { const { id, action } = await ctx.params; const fd = new FormData(); fd.set('id', id); fd.set('action', action); try { await connectorAction(fd); return NextResponse.json({ ok: true, id, action }); } catch (err) { return NextResponse.json({ ok: false, error: err instanceof Error ? err.message : String(err) }, { status: 400 }); } }